﻿using AlumniProject.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AlumniProject
{
    public partial class MasterPageAdmin : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //    lblYear.Text = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);
            //Page.ClientScript.GetPostBackEventReference(this, string.Empty);
            //if (Request.Form["__EVENTTARGET"] == "loginClick")
            //{
            //    LoginJs();
            //}
        }

        //public void LoginJs()
        //{

        //    var username = hdfUser.Value;
        //    var password = hdfPass.Value;
        //    TaiKhoan tk = new TaiKhoan(username, password);

        //    TaiKhoanAccess access = new TaiKhoanAccess();

        //    tk = access.DangNhapSite(tk);
        //    if (tk.TrangThai.Equals(-1))
        //    {
        //        //sResponse.Write("<script>alert('"+tk.Description+"');</script>");
        //        lblError.Text = "Đăng nhập không thành công!";

        //    }
        //    else
        //    {
        //        Session["user"] = tk.TenDangNhap;
        //        Session["name"] = " " + tk.Name;
        //    }
        //}

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session["user"] = null;
            Page_Load(sender, e);
        }

        [ScriptMethod, WebMethod]
        protected void LogOut()
        {
            Session["user"] = null;
            Page_Load(new object(), new EventArgs());
        }
    }
}